﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace dzs.Web.materialinfo
{
    public partial class Add :Web.Admin.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtproid.Text.Trim().Length == 0)
            {
                strErr += "项目编号不能为空！\\n";
            }            
            if (this.txtprojectname.Text.Trim().Length == 0)
            {
                strErr += "项目名称不能为空！\\n";
            }            
            if (this.txtmaterial.Text.Trim().Length == 0)
            {
                strErr += "物料描述不能为空！\\n";
            }             
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string proid = this.txtproid.Text;
            string usework = this.txtusework.Text;
            string projectname = this.txtprojectname.Text;
            string projecttype = this.txtprojecttype.Text;
            string supplier = this.txtsupplier.Text;
            string material = this.txtmaterial.Text;
            decimal nums = decimal.Parse(this.txtnums.Text);
            decimal unitprice = decimal.Parse(this.txtunitprice.Text);
            string unit = this.txtunit.Text;
            string suppliername = this.txtsuppliername.Text;
            string supplierphone = this.txtsupplierphone.Text;
            string bm = this.txtbm.Text;
            string mmodel = txtmodel.Text;
            int mstatus = 0;
            int uid = 0;
            int mtype = int.Parse(this.ddltype.SelectedValue);
            dzs.Model.materialinfo model = new dzs.Model.materialinfo();
            model.proid = proid;
            model.usework = usework;
            model.projectname = projectname;
            model.projecttype = projecttype;
            model.supplier = supplier;
            model.material = material;
            model.nums = nums;
            model.unit = unit;
            model.suppliername = suppliername;
            model.supplierphone = supplierphone;
            model.mstatus = mstatus;
            model.uid = uid;
            model.mtype = mtype;
            model.mbm = bm;
            model.mmodel = mmodel;
            model.unitPrice = unitprice;
            model.cguid = getid();
            //model.
            dzs.BLL.materialinfo bll = new dzs.BLL.materialinfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "../showin.aspx");
        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("../showin.aspx");
        }
    }
}
